#include"process.h"
#define TARGET 1024*1024
#define DSIZE 1024*10

void DownLoad(callback cb)
{
    int target = TARGET;
    int total = 0;
    int testcnt = 100;
    while(total < target)
    {
        usleep(DELAY);
        total += DSIZE;
        double rate = total * 100.0/target;
        if(rate > 50.0 && testcnt)
        {
            total = target/2;
            testcnt--;
        }
        cb(rate);
    }
    cb(MAX_RATE);
    printf("\n");
}

int main()
{
    //process_v2();
    DownLoad(process_v2);
    return 0;
}
